package com.ruoyi.task.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.task.domain.TaskRecommend;
import com.ruoyi.task.service.ITaskRecommendService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 推荐结果管理Controller
 * 
 * @author ruoyi
 * @date 2023-04-09
 */
@RestController
@RequestMapping("/task/recommend")
public class TaskRecommendController extends BaseController
{
    @Autowired
    private ITaskRecommendService taskRecommendService;

    /**
     * 查询推荐结果管理列表
     */
    @PreAuthorize("@ss.hasPermi('task:recommend:list')")
    @GetMapping("/list")
    public TableDataInfo list(TaskRecommend taskRecommend)
    {
        startPage();
        List<TaskRecommend> list = taskRecommendService.selectTaskRecommendList(taskRecommend);
        return getDataTable(list);
    }

    /**
     * 导出推荐结果管理列表
     */
    @PreAuthorize("@ss.hasPermi('task:recommend:export')")
    @Log(title = "推荐结果管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TaskRecommend taskRecommend)
    {
        List<TaskRecommend> list = taskRecommendService.selectTaskRecommendList(taskRecommend);
        ExcelUtil<TaskRecommend> util = new ExcelUtil<TaskRecommend>(TaskRecommend.class);
        util.exportExcel(response, list, "推荐结果管理数据");
    }

    /**
     * 获取推荐结果管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('task:recommend:query')")
    @GetMapping(value = "/{recommendId}")
    public AjaxResult getInfo(@PathVariable("recommendId") Long recommendId)
    {
        return success(taskRecommendService.selectTaskRecommendByRecommendId(recommendId));
    }

    /**
     * 新增推荐结果管理
     */
    @PreAuthorize("@ss.hasPermi('task:recommend:add')")
    @Log(title = "推荐结果管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskRecommend taskRecommend)
    {
        return toAjax(taskRecommendService.insertTaskRecommend(taskRecommend));
    }

    /**
     * 修改推荐结果管理
     */
    @PreAuthorize("@ss.hasPermi('task:recommend:edit')")
    @Log(title = "推荐结果管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TaskRecommend taskRecommend)
    {
        return toAjax(taskRecommendService.updateTaskRecommend(taskRecommend));
    }

    /**
     * 删除推荐结果管理
     */
    @PreAuthorize("@ss.hasPermi('task:recommend:remove')")
    @Log(title = "推荐结果管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recommendIds}")
    public AjaxResult remove(@PathVariable Long[] recommendIds)
    {
        return toAjax(taskRecommendService.deleteTaskRecommendByRecommendIds(recommendIds));
    }
}
